*-- generating interactions 
global PATX ""
local h=0
foreach i of varlist $XVar0  {
local a=`h++'

gen px`a' =`i'    
global PATX "${PATX} px`a'"    	
}

global DATX ""
local h=0
foreach i of varlist  $Xvar0_phy  {
local a=`h++'

gen dx`a' =`i'    
global DATX "${DATX} dx`a'"    	
}



order px* dx*

* patient 
global INTPX ""

unab vars: px* 
local nvar: word count `vars'

forvalues i=1/`nvar' {
    forvalues j=1/`=`i'-1' {
	    
		local x: word `i' of `vars'
		local y: word `j' of `vars'		
		gen `x'X`y'=`x'*`y'
		global INTPX "${INTPX} `x'X`y' "

	}
	
} 

* physician 
global INTDX ""

unab vars: dx* 
local nvar: word count `vars'

forvalues i=1/`nvar' {
    forvalues j=1/`=`i'-1' {	    
		local x: word `i' of `vars'
		local y: word `j' of `vars'		
		gen `x'X`y'=`x'*`y'
		global INTDX "`x'X`y' ${INTDX}"

	}
	
} 

global INTPX_res0 ""

foreach v in $INTPX {
global INTPX_res0 "${INTPX_res0} res0_`v'"	
}

global INTDX_res0 ""

foreach v in $INTDX {
global INTDX_res0 "${INTDX_res0} res0_`v'"	
}

